<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<style>
#myDiv{width: 200px;height: 250px; margin: 10px auto;}
#div1{width:200px; height:200px; background:red;margin-top: 10px;}
</style>
<script>
function setColor(color)
{
	var oDiv= document.getElementById('div1');
	oDiv.style.background = color;
}
</script>
<body>
<div id="myDiv">
    <input type="button" value="变蓝" onclick="setColor('blue')"/>
    <input type="button" value="变红" onclick="setColor('red')"/>
    <div id="div1"></div>
</div>
</body>
</html>
